{include file="layout/header" title="学生选课表单" /}
<h4>你的选课机会只有一次，请慎重考虑，一旦选择无法改变！</h4>
<p></p>
<form method="post" action="{:url('Index/Enrollment/index')}" onsubmit="return validate();">
    {:token()}
    <div class="row">
        <div class="col-md-12">
            <div class="table-responsive">
                <table class="table table-condensed table-hover table-bordered table-striped">
                    <tr>
                        <th>选择</th>
                        <th>校区</th>
                        <th>课程名称</th>
                        <th>任教老师</th>
                        <th>报名情况</th>
                    </tr>
                    {volist name='list' id='course'}
                    <tr>
                        <td><input type="radio" name="course_id" value="{$course.course_id}" {:count($course.enrollments) >= $course.course_number ? "disabled" : ""} /></td>
                        <td>{:$course.school_id == 0 ? '松风':'白马'}</td>
                        <td>{$course.course_name}</td>
                        <td>{$course.teacher}</td>
                        <td>
                            {:count($course.enrollments)}/{$course.course_number}
                        </td>
                    </tr>
                    {/volist}
                </table>
            </div>
        </div>
    </div>
    <p style="text-align:center;">
        <input type="submit" value="确定" class="btn btn-primary" />&nbsp;&nbsp;<input type="reset" value="重置" class="btn btn-primary" />
    </p>
</form>
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close"
                        data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    提示信息
                </h4>
            </div>
            <div class="modal-body" id="modal-body"></div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary"
                        data-dismiss="modal">
                    关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<script language="javascript" type="text/javascript">
    function checkRadios(CourseID) {
        var checked = false;
        var radios = document.getElementsByName(CourseID);
        for (var x = 0; x < radios.length; x++) {
            checked = checked || radios[x].checked;
        }
        return checked;
    }
    function validate() {
        var flag1 = false;
        var info = "";
        flag1 = checkRadios("course_id");
        if (!flag1) {
            info += "请至少选择一门课程！<br/>";
        }
        if (info != "") {
            //alert(info);
            document.getElementById("modal-body").innerHTML = info;
            $('#myModal').modal('show');
        }
        return (flag1);
    }
</script>
{include file="layout/footer" /}
